package com.xwt.pattern.builder;

import java.util.ArrayList;

/**
 * Author:  Steven Xiao
 * Description:学习一下社会主义核心价格观吧
 * Date:  2016/3/15
 * Time:  11:54
 */
public abstract class CarModel {
    //基本方法执行的顺序
    private ArrayList<String> sequence = new ArrayList<String>();

    //启动
    protected abstract void start();

    //停止
    protected abstract void stop();

    //喇叭滴滴
    protected abstract void alarm();

    //引擎轰隆隆
    protected abstract void engineBoom();

    //模型会跑
    public final void run() {
        for (int i = 0; i < this.sequence.size(); i++) {
            String actionName = this.sequence.get(i);
            if (actionName.equalsIgnoreCase("start")) {
                this.start();//开始汽车
            } else if (actionName.equalsIgnoreCase("stop")) {
                this.stop();//停止洗车
            } else if (actionName.equalsIgnoreCase("alarm")) {
                this.alarm();//喇叭开始叫了
            } else if (actionName.equalsIgnoreCase("engine boom")) {
                this.engineBoom(); //如果是engine boom 关键字
            }
        }
    }

    //把传递过来的值传递到类内
    public final void setSequence(ArrayList<String> sequence) {
        this.sequence = sequence;
    }

}
